package com.topView2;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @Author: huangzhigao
 * @Date: 2023/2/12 17:02
 */
public class leecode78 {
    public List<List<Integer>> subsets(int[] nums) {
        List<List<Integer>> res = new ArrayList<>();
        back(nums, 0, new LinkedList<>(), res);
        return res;
    }


    public void back(int[] nums, int index, LinkedList<Integer> path, List<List<Integer>> res) {
        res.add(new ArrayList<>(path));
        for (int i = index; i < nums.length; i++) {
            path.addLast(nums[i]);
            back(nums, i + 1, path, res);
            path.removeLast();
        }
    }

}
